<?php
/**
 * Created by PhpStorm.
 * User: trisatria
 * Date: 1/6/14
 * Time: 3:32 PM
 */

namespace Admin\Model;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class AdminTopic{
    //1
    public $id;
    //2
    public $user_id;
    //3
    public $title;
    //4
    public $images;
    //5
    public $price;
    //6
    public $show_price;
    //7
    public $short_description;
    //8
    public $full_description;
    //9
    public $expire_date;
    //10
    public $status;
    //11
    public $cat_id;
    //12
    public $create_date;
    //13
    public $topic_type;
    //14
    public $topic_location;
    //15
    public $is_brandnew;
    //16
    public $thumb;
    //17
    public $up_date;
    //18
    public $slug;
    //19
    public $is_public;
    //20
    public $viewed;
    protected $inputFilter;


    public function exchangeArray($data){
        $this->id     = (isset($data['id'])) ? $data['id'] : null;
        $this->user_id = (isset($data['user_id'])) ? $data['user_id'] : null;
        $this->title  = (isset($data['title'])) ? $data['title'] : null;

        $this->images = (isset($data['images'])) ? $data['images'] : null;
        $this->price = (isset($data['price'])) ? $data['price'] : null;
        $this->show_price  = (isset($data['show_price'])) ? $data['show_price'] : null;

        $this->short_description     = (isset($data['short_description'])) ? $data['short_description'] : null;
        $this->full_description = (isset($data['full_description'])) ? $data['full_description'] : null;
        $this->expire_date  = (isset($data['expire_date'])) ? $data['expire_date'] : null;
        $this->status = (isset($data['status'])) ? $data['status'] : null;
        $this->cat_id  = (isset($data['cat_id'])) ? $data['cat_id'] : null;
        $this->create_date  = (isset($data['create_date'])) ? $data['create_date'] : date("Y-m-d H:i:s");
        $this->topic_type = (isset($data['topic_type'])) ? $data['topic_type'] : null;
        $this->topic_location = (isset($data['topic_location'])) ? $data['topic_location'] : null;
        $this->is_brandnew = (isset($data['is_brandnew'])) ? $data['is_brandnew'] : null;
        $this->thumb = (isset($data['thumb'])) ? $data['thumb'] : '/img/upload/no_photo_avalable.jpg';
        $this->up_date = (isset($data['up_date'])) ? $data['up_date'] : time();
        $this->slug = (isset($data['slug'])) ? $data['slug'] : time();
        $this->is_public = (isset($data['is_public'])) ? $data['is_public'] : 1;
        $this->viewed = (isset($data['viewed'])) ? $data['viewed'] : 0;
    }
    //form use
    public function getInputFilter() {
        if (!$this->inputFilter) {
            //1
            $inputFilter = new InputFilter();
            $factory     = new InputFactory();
            //2
            $inputFilter->add($factory->createInput(array(
                'name'     => 'id',
                'required' => false,
            )));
            //3
            $inputFilter->add($factory->createInput(array(
                'name'     => 'user_id',
                'required' => false,
            )));
            //4
            $inputFilter->add($factory->createInput(array(
                'name'     => 'title',
                'required' => true,
            )));
            //5
            $inputFilter->add($factory->createInput(array(
                'name'     => 'images',
                'required' => false,
            )));
            //6
            $inputFilter->add($factory->createInput(array(
                'name'     => 'price',
                'required' => false,

            )));
            //7
            $inputFilter->add($factory->createInput(array(
                'name'     => 'show_price',
                'required' => false,

            )));
            //8
            $inputFilter->add($factory->createInput(array(
                'name'     => 'short_description',
                'required' => true,

            )));
            //9

            $inputFilter->add($factory->createInput(array(
                'name'     => 'full_description',
                'required' => true,

            )));
            //10

            $inputFilter->add($factory->createInput(array(
                'name'     => 'status',
                'required' => false,

            )));
            //11
            $inputFilter->add($factory->createInput(array(
                'name'     => 'cat_id',
                'required' => false,

            )));
            //12
            $inputFilter->add($factory->createInput(array(
                'name'     => 'create_date',
                'required' => false,

            )));

            //13

            $inputFilter->add($factory->createInput(array(
                'name'     => 'expire_date',
                'required' => false,

            )));
            //14
            $inputFilter->add($factory->createInput(array(
                'name'     => 'topic_type',
                'required' => false,

            )));
            //15
            $inputFilter->add($factory->createInput(array(
                'name'     => 'topic_location',
                'required' => false,

            )));
            //16
            $inputFilter->add($factory->createInput(array(
                'name'     => 'is_brandnew',
                'required' => false,

            )));
            //17
            $inputFilter->add($factory->createInput(array(
                'name'     => 'thumb',
                'required' => false,

            )));
            //18
            $inputFilter->add($factory->createInput(array(
                'name'     => 'up_date',
                'required' => false,

            )));

            //19

            $inputFilter->add($factory->createInput(array(
                'name'     => 'slug',
                'required' => false,

            )));
            //20
            $inputFilter->add($factory->createInput(array(
                'name'     => 'viewed',
                'required' => false,

            )));

            //21
            $inputFilter->add($factory->createInput(array(
                'name'     => 'topic_type',
                'required' => false,

            )));

            $this->inputFilter = $inputFilter;
        }

        return $this->inputFilter;
    }

}
